<template>
    <div>
        <el-header height="36px">
            <header-title :title="headerTitle" />
        </el-header>
        <component v-if="showComponents" :prj-stage="''" :prj-id="prjDetails.prjId" :prj-type="prjDetails.prjType"
            :is="page" v-for="page in pageSetting" :key="page" :ref="page" />
    </div>
</template>

<script>
import JnPrjDetail from '@/components/jn/JnPrjDetail.vue'
import HeaderTitle from '@/components/basic/HeaderTitle'
import GlobalTabs from '@/views/finalAccounts/finalAccountsSendReview/components/globalTabs.vue'
import CostInfo from '@/views/finalAccounts/finalAccountsSendReview/components/costInfno.vue'
import FinalAccountAudit from '@/views/finalAccounts/finalAccountsSendReview/components/finalAccountAudit.vue'
import ZrAttachmetl from '@/components/zr/ZrAttachmetl.vue'
import {
    getPrjDetailApi
} from '@/api/acceptance/index'
import { getDropdownDataApi } from '@/api/finalAccounts/index'
import { mapActions, mapMutations } from 'vuex'
export default {
    name: "FinlAccountsSendReview",
    components: {
        HeaderTitle,
        GlobalTabs,
        CostInfo,
        FinalAccountAudit,
        JnPrjDetail,
        ZrAttachmetl
    },
    provide() {
        return {
            prjDetail: () => this.prjDetails,
        }
    },
    data() {
        return {
            headerTitle: '',
            pageSetting: ['JnPrjDetail', 'CostInfo', 'FinalAccountAudit', 'GlobalTabs', 'ZrAttachmetl'],
            prjDetails: {},
            auditInfo: {},
            dicLists: {},
            showComponents: false
        }
    },
    methods: {
        ...mapActions('finalAccounts', ['getAuditInfo']),
        ...mapMutations('finalAccounts', ['setDicLists']),
        async getInitPrjDetail() {
            try {
                const { data } = await getPrjDetailApi(this.$route.query.prjId)
                this.prjDetails = data
                const detailTitle = !this.$route.query.status ? '-决算送审项目详情' : ''
                this.headerTitle = this.prjDetails.prjName + detailTitle
                this.getAuditInfo({
                    prjId: this.$route.query.prjId,
                    bizSeq: this.$route.query.bizSeq ? this.$route.query.bizSeq : ''
                })
                this.showComponents = true
            } catch (error) {
                console.log(error);
            }
        },
        async getDictData() {
            const arr = ['FIN_AUDIT_STATE', 'IS_RAILWAY', 'PL_TYPE', 'IS_PUSH', 'PROJ_TYPE', 'COF_YESORNO']
            const promises = arr.map(item => getDropdownDataApi(item))
            const results = await Promise.all(promises)
            arr.forEach((item, i) => {
                this.$set(this.dicLists, item, results[i].data ?? [])
            })
            this.setDicLists(this.dicLists)
        },
    },
    async created() {
        await this.getInitPrjDetail()
        await this.getDictData()
    }

}
</script>
<style lang="scss" scoped></style>